package stream;

import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.*;
/**
 * @author oldliu
 * @since 1.0
 */
public class Stream1 {
    public static void main(String[] args) {
        Stream<Integer> is = Stream.of(1, 2, 3, 4);
        is.forEach(System.out::println);

        List<Double> list=new ArrayList<>();
        list.add(3.5);
        list.add(31.5);
        list.add(13.5);
        list.add(13.6);
        list.add(2.4);
        list.add(44.1);
        //list.stream().forEach(System.out::print);
        list.stream().forEach(x->{System.out.print(x+" ");});
        System.out.println();
        System.out.println("大于20的数字，放入集合：");
        List<Double> collect = list.stream().filter(x -> x > 20).collect(Collectors.toList());
        System.out.println(collect);
        boolean b = list.stream().anyMatch(x -> x>20);
        System.out.println("有没有大于20的？"+b);
    }
}
